<template>
  <div id="globalSider">
    <a-menu
      :style="{ width: '200px', height: '100%' }"
      :default-open-keys="['0']"
      :default-selected-keys="['0_2']"
      breakpoint="xl"
      @collapse="onCollapse"
      @menu-item-click="doClickMenu"
    >
      <a-sub-menu key="0">
        <template #icon>
          <icon-apps></icon-apps>
        </template>
        <template #title>
          <h2>{{ store.state.user.loginUser.userAccount }}</h2>
        </template>
        <a-menu-item
          key="/profile/index"
          v-if="store.state.user.loginUser.userRole !== ACCESS_ENUM.NOT_LOGIN"
        >
          首页
        </a-menu-item>
        <a-menu-item
          key="/profile/studentManage"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.STUDENT"
        >
          个人信息
        </a-menu-item>
        <a-menu-item
          key="/profile/student"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.STUDENT"
        >
          学生资料
        </a-menu-item>
        <a-menu-item
          key="/profile/jobProvided"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.STUDENT"
        >
          岗位提供
        </a-menu-item>
        <a-menu-item
          key="/profile/resume"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.STUDENT"
        >
          个人简历
        </a-menu-item>
        <a-menu-item
          key="/profile/teaJobProvided"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.TEACHER"
        >
          教师提供岗位
        </a-menu-item>
        <a-menu-item
          key="/profile/studentShow"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.TEACHER"
        >
          学生信息展示
        </a-menu-item>
        <a-menu-item
          key="/profile/addJob"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.TEACHER"
        >
          添加岗位信息
        </a-menu-item>
        <a-menu-item
          key="/profile/check"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.ADMIN"
        >
          学生就业审核
        </a-menu-item>
        <a-menu-item
          key="/profile/apply"
          v-if="store.state.user.loginUser.userRole === ACCESS_ENUM.TEACHER"
        >
          学生就业申请
        </a-menu-item>
      </a-sub-menu>
    </a-menu>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import { computed, ref } from "vue";
import { useStore } from "vuex";
import ACCESS_ENUM from "../access/accessEnum";
import {
  IconMenuFold,
  IconMenuUnfold,
  IconApps,
  IconBug,
  IconBulb,
} from "@arco-design/web-vue/es/icon";

const router = useRouter();
const store = useStore();

//默认页面
const selectedKeys = ref(["/"]);

router.afterEach((to, from, failure) => {
  selectedKeys.value = [to.path];
});

const doClickMenu = (key: string) => {
  router.push({
    path: key,
  });
};
</script>

<style scoped>
#globalSider {
}
</style>
